import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import Layouts from '@/layouts'
import BaqsjLayouts from '@/baqsjLayouts'

/* Router Modules */
// import componentsRouter from './modules/components'
// import chartsRouter from './modules/charts'
// import tableRouter from './modules/table'
// import nestedRouter from './modules/nested'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/',
    component: () => import('@/components/headerLayout/index.vue'),
    redirect: '/',
    mid: 'business',
    children: [{
      path: '/',
      component: () => import('@/views/business/dashboard'),
      name: 'bizdashboard'
    },
    {
      path: '/biz/draft',
      component: () => import('@/views/business/draft'),
      name: 'bizdraft'
    },
    {
      path: '/biz/my',
      component: () => import('@/views/business/my'),
      name: 'bizmy'
    }, {
      path: '/biz/todo',
      component: () => import('@/views/business/todo'),
      name: 'biztodo'
    }, {
      path: '/biz/done',
      component: () => import('@/views/business/done'),
      name: 'bizdone'
    }, {
      path: '/biz/ccRecord',
      component: () => import('@/views/business/ccRecord'),
      name: 'bizccRecord'
    }, {
      path: '/biz/message',
      component: () => import('@/views/business/message'),
      name: 'bizmessage'
    }, {
      path: '/biz/app',
      component: () => import('@/views/business/app'),
      name: 'bizapp'
    }
    ]
  },

  {
    path: '/profile',
    component: Layout,
    redirect: '/profile/index',
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/views/profile/index'),
        name: '个人中心',
        meta: { title: '个人中心', icon: 'user', noCache: true }
      }
    ]
  },
  // {
  //   path: '/quality',
  //   hidden: false,
  //   children: [
  //     {
  //       path: '/quality/index',
  //       hidden: false,
  //       component: () => import('@/views/quality/home/index.vue'),
  //       name: 'HomeIndex',
  //       mid: 'quality',
  //       meta: {
  //         title: '首页',
  //         icon: 'edit',
  //         activeMenu: '',
  //         noCache: true
  //       }
  //     },
  //     {
  //       path: '/scoreFormLib/addScoreForm',
  //       hidden: true,
  //       children: [],
  //       name: 'AddScoreForm',
  //       mid: 'quality',
  //       component: () => import('@/views/quality/scoreFormLib/addScoreForm.vue'),
  //       meta: {
  //         title: '新建评分表单',
  //         icon: 'server',
  //         activeMenu: '',
  //         noCache: true
  //       }
  //     },
  //     {
  //       path: '/examinationPlan',
  //       hidden: false,
  //       component: () => import('@/views/quality/examinationPlan/index.vue'),
  //       name: 'ExaminationPlan',
  //       mid: 'quality',
  //       meta: {
  //         title: '考核计划',
  //         icon: 'edit',
  //         activeMenu: '',
  //         noCache: true
  //       }
  //     },
  //     {
  //       path: '/assessmentPlanTable',
  //       hidden: false,
  //       component: () => import('@/views/quality/assessmentPlanTable/index.vue'),
  //       name: 'AssessmentPlanTable',
  //       mid: 'quality',
  //       meta: {
  //         title: '考核任务',
  //         icon: 'edit',
  //         activeMenu: '',
  //         noCache: true
  //       }
  //     },
  //     {
  //       path: '/detail',
  //       hidden: true,
  //       component: () => import('@/views/quality/detail/index.vue'),
  //       name: 'Detail',
  //       mid: 'quality',
  //       meta: {
  //         title: '详情',
  //         icon: 'edit',
  //         activeMenu: '',
  //         noCache: true
  //       }
  //     },
  //     {
  //       path: '/allRectificationProjects',
  //       hidden: false,
  //       component: () => import('@/views/quality/allRectificationProjects/index.vue'),
  //       name: 'AllRectificationProjects',
  //       mid: 'zlkh',
  //       meta: {
  //         title: '全部整改项目',
  //         icon: 'edit',
  //         activeMenu: '',
  //         noCache: true
  //       }
  //     },
  //     {
  //       path: '/waitingApprove',
  //       hidden: false,
  //       component: () => import('@/views/quality/waitingApprove/index.vue'),
  //       name: 'WaitingApprove',
  //       mid: 'zlkh',
  //       meta: {
  //         title: '医务处待复核项目',
  //         icon: 'edit',
  //         activeMenu: '',
  //         noCache: true
  //       }
  //     },
  //     {
  //       path: '/deptRectificationProjects',
  //       hidden: false,
  //       component: () => import('@/views/quality/deptRectificationProjects/index.vue'),
  //       name: 'DeptRectificationProjects',
  //       mid: 'zlkh',
  //       meta: {
  //         title: '科室整改项目',
  //         icon: 'edit',
  //         activeMenu: '',
  //         noCache: true
  //       }
  //     },
  //     {
  //       path: '/deptWaitingApprove',
  //       hidden: false,
  //       component: () => import('@/views/quality/deptWaitingApprove/index.vue'),
  //       name: 'deptWaitingApprove',
  //       mid: 'zlkh',
  //       meta: {
  //         title: '科室待复核项目',
  //         icon: 'edit',
  //         activeMenu: '',
  //         noCache: true
  //       }
  //     },
  //     {
  //       path: '/evaluationMaintenance',
  //       hidden: false,
  //       component: () => import('@/views/quality/evaluationMaintenance/index.vue'),
  //       name: 'EvaluationMaintenance',
  //       mid: 'zlkh',
  //       meta: {
  //         title: '评分表单库',
  //         icon: 'edit',
  //         activeMenu: '',
  //         noCache: true
  //       }
  //     },
  //     {
  //       path: '/settingZLKH',
  //       hidden: false,
  //       component: () => import('@/views/menu-nesting/index.vue'),
  //       name: 'SettingZLKH',
  //       mid: 'zlkh',
  //       meta: {
  //         title: '系统设置',
  //         icon: 'edit',
  //         activeMenu: '',
  //         noCache: true
  //       },
  //       children: [
  //         {
  //           path: '/sholiday',
  //           hidden: false,
  //           children: [],
  //           name: 'Sholiday',
  //           mid: 'zlkh',
  //           component: () => import('@/views/quality/setting/sholiday/index.vue'),
  //           meta: {
  //             title: '节假日配置',
  //             icon: 'server',
  //             activeMenu: '',
  //             noCache: true
  //           }
  //         },
  //         {
  //           path: '/evaluationElement',
  //           hidden: false,
  //           children: [],
  //           name: 'EvaluationElement',
  //           mid: 'zlkh',
  //           component: () => import('@/views/quality/setting/evaluationElement/index.vue'),
  //           meta: {
  //             title: '评估方式管理',
  //             icon: 'server',
  //             activeMenu: '',
  //             noCache: true
  //           }
  //         }
  //       ]
  //     }
  //   ],
  //   name: 'Quality',
  //   mid: 'quality',
  //   meta: {
  //     'title': '医疗质量管理',
  //     'icon': 'list',
  //     'activeMenu': '',
  //     'noCache': true
  //   },
  //   component: BaqsjLayouts
  // },

  {
    path: '/newBaqsj',
    hidden: false,
    children: [
      {
        path: '/home',
        hidden: false,
        component: () => import('@/views/menu-nesting/index.vue'),
        name: 'Home',
        mid: 'baqsj',
        meta: {
          title: '我的上报',
          icon: 'edit',
          activeMenu: '',
          noCache: true
        },
        children: [
          {
            path: '/newBaqsj/report',
            hidden: false,
            children: [],
            name: 'Apply',
            mid: 'baqsj',
            component: () => import('@/views/newBaqsj/apply/home.vue'),
            meta: {
              title: '我要上报',
              icon: 'server',
              activeMenu: '',
              noCache: true
            }
          },
          {
            path: '/newBaqsj/myConcern',
            hidden: false,
            component: () => import('@/views/newBaqsj/myConcern/index.vue'),
            children: [],
            name: 'myConcern',
            mid: 'baqsj',
            meta: {
              title: '我关注的',
              icon: 'log',
              activeMenu: '',
              noCache: true
            }
          },
          {
            path: '/newBaqsj/myEscalation',
            hidden: false,
            component: () => import('@/views/newBaqsj/myEscalation/index.vue'),
            children: [],
            name: 'myEscalation',
            mid: 'baqsj',
            meta: {
              title: '我上报的',
              icon: 'log',
              activeMenu: '',
              noCache: true
            }
          },
          {
            path: '/newBaqsj/myDraft',
            hidden: false,
            component: () => import('@/views/newBaqsj/myDrafts/index.vue'),
            children: [],
            name: 'myDraft',
            mid: 'baqsj',
            meta: {
              title: '我的草稿',
              icon: 'log',
              activeMenu: '',
              noCache: true
            }
          },
          {
            path: '/newBaqsj/ended',
            hidden: false,
            component: () => import('@/views/newBaqsj/ended/index.vue'),
            children: [],
            name: 'Ended',
            mid: 'baqsj',
            meta: {
              title: '已完结的',
              icon: 'log',
              activeMenu: '',
              noCache: true
            }
          },
          // {
          //   path: '/newBaqsj/messageCenter',
          //   hidden: false,
          //   component: () => import('@/views/newBaqsj/messageCenter/index.vue'),
          //   children: [],
          //   name: 'MessageCenter',
          //   mid: 'baqsj',
          //   meta: {
          //     title: '消息中心',
          //     icon: 'log',
          //     activeMenu: '',
          //     noCache: true
          //   }
          // },
          {
            path: '/newBaqsj/carbonCopy',
            hidden: false,
            component: () => import('@/views/newBaqsj/carbonCopy/index.vue'),
            children: [],
            name: 'carbonCopy',
            mid: 'baqsj',
            meta: {
              title: '抄送我的',
              icon: 'log',
              activeMenu: '',
              noCache: true
            }
          },
          {
            path: '/newBaqsj/lookDetail',
            hidden: true,
            component: () => import('@/views/newBaqsj/lookDetail/index.vue'),
            name: 'lookDetail',
            mid: 'baqsj',
            meta: {
              title: '查看详情',
              icon: 'log',
              activeMenu: '',
              noCache: true
            }
          }
        ]
      },
      {
        path: '/approval',
        hidden: false,
        component: () => import('@/views/menu-nesting/index.vue'),
        name: 'Approval',
        mid: 'baqsj',
        meta: {
          title: '审批中心',
          icon: 'edit',
          activeMenu: '',
          noCache: true
        },
        children: [
          {
            path: '/newBaqsj/pendingMyApproval',
            hidden: false,
            component: () => import('@/views/newBaqsj/pendingMyApproval/index.vue'),
            children: [],
            name: 'PendApproval',
            mid: 'baqsj',
            meta: {
              title: '待我审批的',
              icon: 'log',
              activeMenu: '',
              noCache: true
            }
          },
          {
            path: '/newBaqsj/approved',
            hidden: false,
            component: () => import('@/views/newBaqsj/approved/index.vue'),
            children: [],
            name: 'approved',
            mid: 'baqsj',
            meta: {
              title: '已审批的',
              icon: 'log',
              activeMenu: '',
              noCache: true
            }
          }
        ]
      },
      {
        path: '/qualityControl',
        hidden: false,
        component: () => import('@/views/menu-nesting/index.vue'),
        name: 'QualityControl',
        mid: 'baqsj',
        meta: {
          title: '数据质控',
          icon: 'edit',
          activeMenu: '',
          noCache: true
        },
        children: [
          {
            path: '/newBaqsj/queryData',
            hidden: false,
            component: () => import('@/views/newBaqsj/queryData/index.vue'),
            children: [],
            name: 'queryData',
            mid: 'baqsj',
            meta: {
              title: '数据查询',
              icon: 'log',
              activeMenu: '',
              noCache: true
            }
          },
          {
            path: '/newBaqsj/qualityControl',
            hidden: false,
            component: () => import('@/views/newBaqsj/qualityControl/index.vue'),
            children: [],
            name: 'qualityControl',
            mid: 'baqsj',
            meta: {
              title: '数据质控',
              icon: 'log',
              activeMenu: '',
              noCache: true
            }
          },
          {
            path: '/newBaqsj/hospitalSenseData',
            hidden: false,
            component: () => import('@/views/newBaqsj/hospitalSenseData/index.vue'),
            children: [],
            name: 'hospitalSenseData',
            mid: 'baqsj',
            meta: {
              title: '院感数据',
              icon: 'log',
              activeMenu: '',
              noCache: true
            }
          },
          {
            path: '/newBaqsj/handNumbnessData',
            hidden: false,
            component: () => import('@/views/newBaqsj/handNumbnessData/index.vue'),
            children: [],
            name: 'handNumbnessData',
            mid: 'baqsj',
            meta: {
              title: '手麻数据',
              icon: 'log',
              activeMenu: '',
              noCache: true
            }
          }
        ]
      }
    ],
    name: 'NewBaqsj',
    mid: 'baqsj',
    meta: {
      'title': '不安全事件上报平台',
      'icon': 'list',
      'activeMenu': '',
      'noCache': true
    },
    component: BaqsjLayouts
  }

]

export const asyncRoutes = []

const createRouter = () =>
  new Router({
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
